/**
 * 
 */
const http = require('http');

let options = {
    protocol: 'http:',
    host: 'localhost',
    port: 3000,
    method: 'GET',
    path: '/books'
}

let req = http.request(options, (resp) => {
    console.log(`状态码: ${resp.statusCode}`);
    console.log(`响应头: ${JSON.stringify(resp.headers)}`);
    resp.setEncoding('utf8');

    let _data = '';
    resp.on('data', (chunk) => {
        _data += chunk;
    });
    resp.on('end', () => {
        console.log(_data);
    });
});

req.end();

